import requests
import json




def send_userAuthNew_request(user_ip,wlanacname,encrypted_user_ip,encrypted_user_name,encrypted_wlanacname,encrypted_password,time_code):
    url = "http://125.74.71.52/rasPortal/userAuthNew.do"
#    url = "http://125.74.71.52/rasPortal/userAuthNew.do?zKFl8WhS=0mpq_lalqEEvLv66kUeuD4ihxqxwqAYcvsveSS1TcnRbyDcISw1pTEDe7irYBLN8RpNEM0cGIs_3c1SItYiNOtCIAHXbBVgcO"   
    params = {
    "zKFl8WhS": "0Ch7bZGlqEr4bKHz7hlPMcLHpNCzK5Ara5sWu0Fl5uG2wo38bkGFhEotwZ4_ElpWjcv2Taf1vU3Iojq.pD3eEoOg23paRghPR"
    }

    headers = {
        "Accept": "*/*",
        "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
        "Connection": "keep-alive",
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "Cookie": ("JSESSIONID=891EE7401CEC40C95B23923C84E219FD; XMD3ydMbIABqS=600vLbXnRH5BDcxS8U4R0cWwAVqTEGLjxE_4rzMr2Y7Iy3kEgzVyr0EWBJpX9YGHTrXg3dUOa.aii0KRAcnv3VQa; enable_XMD3ydMbIABq=true; XMD3ydMbIABqT=0icZpWPhDyu9b5vSgmYTAEbHQMr4K4PRRCeBvlBt70KLSIrsy3GUaxM0JXms68ZQKvHbwtmz_dbgjW1pWfcPkkdLiu7jF39D_FXvfbdLql9.wnenXLxn6_wlzNRT6PyGv.UdvY_Gwf2uxdCnbDR7CwqHBxyrM_SYqb6GhYNYvi_NaU.vCZxocS.9MaBFmgOopS1XZwg0bNQRy7iVLVZhhs.CfBH07Bn4chJ33zw4qc_CARvwsQzAvHUe4ngN3DjduB4_GHhg7LtwSdXa7yIxs8NYyi57wdjyX_KvKtzv8lUYK._73K7OSTrVt4rZEAMItjKQP3O09rbOKCrmHRddEP.ta7G01O0EL4C25TwkSe4V"),
        "Origin": "http://125.74.71.52",
        "Referer": "http://125.74.71.52/rasHome/dist/login.html?wlanuserip=" + user_ip + "&wlanacname=" + wlanacname,
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0",
        "X-Requested-With": "XMLHttpRequest"
    }
    
    data = {
        "req": json.dumps({
            "bas_name": encrypted_wlanacname,
            "user_ip": encrypted_user_ip,
            "client_type": "PC",
            "client_version": "2.5.7",
            "password": encrypted_password,
            "user_name": encrypted_user_name,
            "device_name": "DELL",
            "time_code": time_code,
            "InterfaceType": "encryption"
        })
    }

    response = requests.post(url, params=params, headers=headers, data=data, verify=False)
    print("url:", response.url)
    print("headers:", response.headers)
    print("Status Code:", response.status_code)
    print("Response Headers:", response.headers)
    return response.text



def send_VerificationCode_request(user_ip,wlanacname):
    url="http://125.74.71.52/rasPortal/VerificationCode.do"
    params = {
    "zKFl8WhS": "0Ch7bZGlqEr4bKHz7hlPMcLHpNCzK5Ara5sWu0Fl5uG2wo38bkGFhEotwZ4_ElpWjcv2Taf1vU3Iojq.pD3eEoOg23paRghPR"
    }

    headers = {
        "Accept": "*/*",
        "accept-encoding": "gzip, deflate",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Connection": "keep-alive",
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "Cookie": ("JSESSIONID=891EE7401CEC40C95B23923C84E219FD; XMD3ydMbIABqS=600vLbXnRH5BDcxS8U4R0cWwAVqTEGLjxE_4rzMr2Y7Iy3kEgzVyr0EWBJpX9YGHTrXg3dUOa.aii0KRAcnv3VQa; enable_XMD3ydMbIABq=true; XMD3ydMbIABqT=0icZpWPhDyu9b5vSgmYTAEbHQMr4K4PRRCeBvlBt70KLSIrsy3GUaxM0JXms68ZQKvHbwtmz_dbgjW1pWfcPkkdLiu7jF39D_FXvfbdLql9.wnenXLxn6_wlzNRT6PyGv.UdvY_Gwf2uxdCnbDR7CwqHBxyrM_SYqb6GhYNYvi_NaU.vCZxocS.9MaBFmgOopS1XZwg0bNQRy7iVLVZhhs.CfBH07Bn4chJ33zw4qc_CARvwsQzAvHUe4ngN3DjduB4_GHhg7LtwSdXa7yIxs8NYyi57wdjyX_KvKtzv8lUYK._73K7OSTrVt4rZEAMItjKQP3O09rbOKCrmHRddEP.ta7G01O0EL4C25TwkSe4V"),
        "Origin": "http://125.74.71.52",
        "Referer": "http://125.74.71.52/rasHome/dist/login.html?wlanuserip=" + user_ip + "&wlanacname=" + wlanacname,
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0",
        "X-Requested-With": "XMLHttpRequest"
    }

    response = requests.post(url,params=params,headers=headers, verify=False)
    print("url:", response.url)
    print("headers:", response.headers)
    print("Status Code:", response.status_code)
    print("Response Headers:", response.headers)
    return response.text

